package com.book.book;

/***
 * @Author Lin
 * @Date Create By 16:34 2017/10/4
 * @Description
 */
public enum NovelSiteEnum {
    DingDianXiaoShuo(1, "x23us.com"),
    ShenShuWang(2, "shenshuw.com"),
    BiQuGe(3, "b5200.org"),
    BiXiaWenXue(4, "bixia.org"),
    KanShuZhong(5, "kanshuzhong.com"),
    BiXiaWenXue9(6, "bxwx9.org");
    private int id;
    private String url;

    private NovelSiteEnum(int id, String url){
        this.id = id;
        this.url = url;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public static NovelSiteEnum getEnmuById (int id){
        switch (id){
            case 1 : return DingDianXiaoShuo;
            case 2 : return ShenShuWang;
            case 3 : return BiQuGe;
            case 4 : return BiXiaWenXue;
            default:throw new RuntimeException("id="+id+"是不被支持的小说网址");
        }
    }

    public static NovelSiteEnum getEnumByUrl (String url){
        for (NovelSiteEnum novelSiteEnum : values()){
            if (url.contains(novelSiteEnum.url)){
                return novelSiteEnum;
            }
        }
        throw new RuntimeException("url="+url+"是不被支持的小说网址");
    }
}
